#include "CLight.h"
#include "GameSceneManager.h"
#include "GameObjectManager.h"
#include "GameSystemManager.h"

comp_id_type CLight::mFamilyID = "CLight";
comp_id_type CLight::mComponentID = "CLight";

comp_id_type CLightTemplate::mFamilyID = "CLight";
comp_id_type CLightTemplate::mComponentID = "CLight";

//Ogre::String CLight::meshFileName = "";
//Ogre::String CLightTemplate::meshFileName = "";

CLightTemplate::CLightTemplate() {

}
//CLightTemplate::CLightTemplate(Ogre::String meshName = "") {
	//meshFileName = meshName;
//}
CLightTemplate::~CLightTemplate() {

}
GameComponent *CLightTemplate::makeComponent() {
	CLight *comp = new CLight(this);
	return comp;
}

CLight::CLight()
{
	std::string name;
	name = "CLightComponent" + StringConverter::toString(GameObjectManager::getSingleton()->getNextCompIndex());

	mLight = GameSceneManager::getSingleton()->getSceneManager()->createLight(name);
	mLight->setType(Light::LT_DIRECTIONAL);
}
CLight::CLight(unsigned int lightType)
{
	std::string name;
	name = "CLightComponent" + StringConverter::toString(GameObjectManager::getSingleton()->getNextCompIndex());

	mLight = GameSceneManager::getSingleton()->getSceneManager()->createLight(name);
	mLight->setType(Light::LT_DIRECTIONAL);
	mLight->setDirection(Vector3(0.0f, -0.5f, 1.0f));
}
CLight::CLight(CLightTemplate *templ)
{

}
CLight::~CLight()
{
	GameSceneManager::getSingleton()->getSceneManager()->destroyLight(mLight);
}

void CLight::update() {

}

void CLight::setup() {
	//This is to keep track of objects, when i cast rays on them, i get the name of the owner
	std::string objectName;
	objectName = getOwnerObject()->getID().c_str();

	mLight->setUserAny( Ogre::Any(objectName) );
	
}
